package com.android.showRoomApp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

/**
 * 启动页
 */
public class LauncherActivity extends AppCompatActivity {

    private static final int times = 3000; //设置启动图停留时间
    private SharedPreferences sharedPreferences;
    private String no;
    private String password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);

        sharedPreferences = getSharedPreferences(getString(R.string.app_shareFile),MODE_PRIVATE);
        no = sharedPreferences.getString("no","");
        password = sharedPreferences.getString("password","");

        if (no.isEmpty() || password.isEmpty()) {
            // 没有数据，跳转设置页面
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(LauncherActivity.this, SettingActivity.class);
                    startActivity(intent);
                    finish();
                }
            }, times);
        } else {
            // 有数据，跳转首页
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(LauncherActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }
            }, times);
        }
    }
}
